package com.xzy.spring.demo.registrar;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

import java.util.ArrayList;

/**
 * @author xzy
 * @date 2021/2/8 21:38
 * 说明：
 */
public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
    /**
     * {@inheritDoc}
     *
     * @implNote 手动将Bean定义信息注册进IOC容器
     */
    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        registry.registerBeanDefinition("registrarBeanA", new RootBeanDefinition(RegistrarBeanA.class));
        registry.registerBeanDefinition("registrarBeanB", new RootBeanDefinition(RegistrarBeanB.class));
        registry.registerBeanDefinition("registrarBeanC", new RootBeanDefinition(RegistrarBeanC.class));
    }
}
